<?php

namespace System\Lib\Twitter\Auth;

/**
 * Description of ASignatureMethod
 *
 * @author Elton Schivei Costa
 */
abstract class ASignatureMethod extends \System\Types\Object
{

    /**
     * Needs to return the name of the Signature Method (ie HMAC-SHA1)
     * @return \System\Types\String
     */
    abstract public function GetName();

    /**
     * Build up the signature
     * NOTE: The output of this function MUST NOT be urlencoded.
     * the encoding is handled in OAuthRequest when the final
     * request is serialized
     * @param Request $request
     * @param Consumer $consumer
     * @param Token $token
     * @return \System\Types\String
     */
    abstract public function BuildSignature(Request &$request, Customer &$consumer, Token &$token);

    /**
     * Verifies that a given signature is correct
     * @param Request $request
     * @param Customer $consumer
     * @param Token $token
     * @param \System\Types\String $signature
     * @return \System\Types\Boolean
     */
    public function CheckSignature(Request &$request, Customer &$consumer, Token &$token, \System\Types\String &$signature)
    {
        $built = $this->BuildSignature($request, $consumer, $token);

        return new \System\Types\Boolean($built == $signature);
    }

}
